package com.hymall.controller.wx;

import com.hymall.bean.MarketTopic;
import com.hymall.bean.common.BasePageInfo;
import com.hymall.bean.common.BaseRespVo;
import com.hymall.bean.common.CommonData;
import com.hymall.service.wx.WxTopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 赵思源
 * @since 2022/07/20 20:01
 * @description:小程序端专题相关
 */
@RestController
@RequestMapping("wx/topic")
public class WxTopicController {

    @Autowired
    WxTopicService wxTopicService;

    /**
     * 小程序专题显示页面
     * @author Zhaosiyuan
     * @date 2022/7/20 0020 20:22
     * http://182.92.235.201:8083/wx/topic/list?page=1&limit=10
     */
    @GetMapping("list")
    public BaseRespVo list(BasePageInfo info){
        CommonData data = wxTopicService.queryTopicList(info);
        return BaseRespVo.ok(data);
    }

    /**
     * 每个专题的详情
     * @author Zhaosiyuan
     * @date 2022/7/20  22:22
     *
     */
    @GetMapping("detail")
    public BaseRespVo detail(Integer id){
        MarketTopic marketTopic;
        marketTopic = wxTopicService.selectTopicById(id);

        Integer[] goods = marketTopic.getGoods();
        return BaseRespVo.ok(goods,marketTopic);
    }

    @GetMapping("related")
    public BaseRespVo related(Integer id){
        BasePageInfo basePageInfo = new BasePageInfo();
        // 按老师设计的页面
        basePageInfo.setPage(1);
        basePageInfo.setLimit(4);
        CommonData data = wxTopicService.queryTopicList(basePageInfo);
        return BaseRespVo.ok(data);
    }

}
